package future;

import com.google.common.util.concurrent.*;
import org.checkerframework.checker.nullness.qual.Nullable;

public class Test03 {
    public static void main(String[] args) {
        ListeningExecutorService service = MoreExecutors.newDirectExecutorService();
        ListenableFuture<?> future = service.submit(() -> 1);
        Futures.addCallback(future, new FutureCallback<Object>() {
            @Override
            public void onSuccess(@Nullable Object o) {
                System.out.println(o);
            }

            @Override
            public void onFailure(Throwable throwable) {
                throwable.printStackTrace();
            }
        }, service);
    }
}
